﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LittleBee.EngUnit
{
	class EUType
	{
		public EUType(string type, string shortType, string system, string name, string shortName, string displayName, float scale, float offset)
		{
			Type = type;
			ShortType = shortType;
			System = system;
			Name = name;
			ShortName = shortName;
			DisplayName = displayName;
			Scale = scale;
			Offset = offset;
		}
		public string Type { get; }
		public string ShortType { get; }
		public string System { get; }
		public string Name { get; }
		public string ShortName { get; }
		public string DisplayName { get; }
		public float Scale { get; }
		public float Offset { get; }
	}

	public class EU
	{
		EUType _eu;

		static EUType[] _EUTypeList =
		{
			new EUType("Uncat", "uncat", "", "", "uncat", "uncat", 0, 0),
			new EUType("Temperature", "temp", "Metric", "Kelvin", "kelvin", "K", 1, 0),
			new EUType("Temperature", "temp", "Metric", "Celsius", "celsius", "°C", 1, -273.15f),
			new EUType("Temperature", "temp", "Metric", "Fahrenheit", "fahrenheit", "°F", 1.8f, -459.666667f),
			new EUType("Temperature", "temp", "Metric", "Reaumur", "reaumur", "R", 0.8f, -218.52f),
			new EUType("Temperature", "temp", "Metric", "Rankine", "rankine", "Rankine", 1.8f, 0),
			new EUType("Delta Temperature", "delta temp", "Metric", "Delta Kelvin", "dk", "△K", 1, 0),
			new EUType("Delta Temperature", "delta temp", "Metric", "Delta Celsius", "dc", "△°F", 1, 0),
			new EUType("Delta Temperature", "delta temp", "Metric", "Delta Fahrenheit", "df", "△°F", 1.8f, 0),
			new EUType("Density", "density", "Metric", "Kilogram per cubic meter", "kg/m3", "kg/m³", 1, 0),
			new EUType("Density", "density", "Metric", "Gram per cubic Centimeter", "g/cm³", "g/cm³", 0.001f, 0),
			new EUType("Density", "density", "Metric", "Gram per cubic meter", "g/m3", "g/m³", 1000, 0),
			new EUType("Density", "density", "Metric", "Milligram per cubic meter", "mg/m3", "mg/m³", 1000000, 0),
			new EUType("Density", "density", "British/American", "Ounce per gallon", "oz/gal", "oz/gal", 0.13f, 0),
			new EUType("Density", "density", "British/American", "Pound per cubic foot", "lb/ft3", "lb/ft³", 0.06f, 0),
			new EUType("Density", "density", "British/American", "Pound per cubic inch", "lb/in3", "lb/in³", 3.61E-05f, 0),
			new EUType("Energy", "energy", "Metric", "Joule", "J", "J", 1, 0),
			new EUType("Energy", "energy", "Metric", "kWh", "kWh", "kWh", 2.78E-07f, 0),
			new EUType("Energy", "energy", "Metric", "MJ", "MJ", "MJ", 1E-06f, 0),
			new EUType("Energy", "energy", "Metric", "kJ", "kJ", "kJ", 0.001f, 0),
			new EUType("Energy", "energy", "Metric", "Ws", "Ws", "Ws", 1, 0),
			new EUType("Energy", "energy", "Metric", "eV", "eV", "eV", 6.24E+18f, 0),
			new EUType("Energy", "energy", "British/American", "Quad", "quad", "quad", 9.48E-19f, 0),
			new EUType("Energy", "energy", "British/American", "Them", "them", "them", 9.48E-09f, 0),
			new EUType("Energy", "energy", "British/American", "British thermal unit", "BTU", "BTU", 0.000948f, 0),
			new EUType("Energy", "energy", "British/American", "Foot-pound", "fp", "fp", 0.74f, 0),
			new EUType("Energy", "energy", "Other", "kcal", "kcal", "kcal", 0.000239f, 0),
			new EUType("Energy", "energy", "Other", "Calories", "cal", "cal", 0.24f, 0),
			new EUType("Energy", "energy", "Other", "Thermie", "th", "th", 2.39E-07f, 0),
			new EUType("Power", "power", "Metric", "Watt", "W", "W", 1, 0),
			new EUType("Power", "power", "Metric", "Milliwatt", "mW", "mW", 1000, 0),
			new EUType("Power", "power", "Metric", "Kilowatt", "kW", "kW", 0.001f, 0),
			new EUType("Power", "power", "Metric", "Megawatt", "MW", "MW", 1E-06f, 0),
			new EUType("Power", "power", "Metric", "Joule per second", "J/s", "J/s", 1, 0),
			new EUType("Power", "power", "Metric", "Horsepower", "hp", "hp", 0.00134f, 0),
			new EUType("Power", "power", "Metric", "Metric horsepower", "metric hp", "metric hp", 0.00136f, 0),
			new EUType("Power", "power", "Metric", "Electrical horsepower", "electrical hp", "Electrical hp", 0.00134f, 0),
			new EUType("Power", "power", "Metric", "Boiler horsepower", "boiler hp", "Boiler horsepower", 0.000102f, 0),
			new EUType("Power", "power", "Metric", "Foot-pounds per minute", "fp/m", "fp/m", 44.25f, 0),
			new EUType("Power", "power", "Metric", "Foot-pounds per second", "fp/s", "fp/s", 0.74f, 0),
			new EUType("Power", "power", "Metric", "dBm", "dBm", "dBm", 30, 0),
			new EUType("Power", "power", "Metric", "Calories per hour", "cal/h", "cal/h", 859.85f, 0),
			new EUType("Power", "power", "Metric", "Kilocalories per hour", "kcal/h", "kcal/h", 0.86f, 0),
			new EUType("Power", "power", "Metric", "British thermal unit per hour", "BTU/h", "BTU/h", 3.41f, 0),
			new EUType("Power", "power", "Metric", "British thermal unit per second", "BTU/s", "BTU/s", 0.000948f, 0),
			new EUType("Power", "power", "Metric", "Ton of refrigeration", "ton of refrigeration", "ton of refrigeration", 0.000284f, 0),
			new EUType("Length", "length", "Metric", "Meter", "m", "m", 1, 0),
			new EUType("Length", "length", "Metric", "Kilometer", "km", "km", 0.001f, 0),
			new EUType("Length", "length", "Metric", "Decimeter", "dm", "dm", 10, 0),
			new EUType("Length", "length", "Metric", "Centimeter", "cm", "cm", 100, 0),
			new EUType("Length", "length", "Metric", "Millimeter", "mm", "mm", 1000, 0),
			new EUType("Length", "length", "Metric", "Micrometer", "um", "µm", 1000000, 0),
			new EUType("Length", "length", "Metric", "Nanometer", "nm", "nm", 1000000000, 0),
			new EUType("Length", "length", "Metric", "Angstrom", "An", "Å", 10000000000, 0),
			new EUType("Length", "length", "Nautical", "Sea mile", "nmi", "nmi", 0.00054f, 0),
			new EUType("Length", "length", "Nautical", "Fathom", "fathom", "Fathom", 0.55f, 0),
			new EUType("Length", "length", "British/American", "League", "league", "League", 0.000207f, 0),
			new EUType("Length", "length", "British/American", "Mile", "mi", "mi", 0.000621f, 0),
			new EUType("Length", "length", "British/American", "Furlong", "furlong", "Furlong", 0.00497f, 0),
			new EUType("Length", "length", "British/American", "Chain", "chain", "Chain", 0.05f, 0),
			new EUType("Length", "length", "British/American", "Rod", "rd", "rd", 0.2f, 0),
			new EUType("Length", "length", "British/American", "Yard", "yd", "yd", 1.09f, 0),
			new EUType("Length", "length", "British/American", "Foot", "ft", "ft", 3.28f, 0),
			new EUType("Length", "length", "British/American", "Link", "link", "Link", 4.97f, 0),
			new EUType("Length", "length", "British/American", "Hand", "hand", "Hand", 9.84f, 0),
			new EUType("Length", "length", "British/American", "inch", "in", "in", 39.37f, 0),
			new EUType("Length", "length", "British/American", "Line", "line", "Line", 393.7f, 0),
			new EUType("Length", "length", "British/American", "Mil", "mil", "mil", 39370.08f, 0),
			new EUType("Length", "length", "British/American", "Thou", "thou", "thou", 39370.08f, 0),
			new EUType("Length", "length", "Astronomical", "Parsec", "pc", "pc", 3.24E-17f, 0),
			new EUType("Length", "length", "Astronomical", "Light year", "ly", "ly", 1.06E-16f, 0),
			new EUType("Length", "length", "Astronomical", "Astronomical unit", "AU", "AU", 6.68E-12f, 0),
			new EUType("Length", "length", "Astronomical", "Light minute", "light minute", "light minute", 5.56E-11f, 0),
			new EUType("Length", "length", "Astronomical", "Light second", "light second", "light second", 3.34E-09f, 0),
			new EUType("Area", "area", "Metric", "Square meter", "m2", "m²", 1, 0),
			new EUType("Area", "area", "Metric", "Square kilometer", "km2", "km²", 1E-06f, 0),
			new EUType("Area", "area", "Metric", "hectare", "ha", "ha", 0.0001f, 0),
			new EUType("Area", "area", "Metric", "Are", "a", "a", 0.01f, 0),
			new EUType("Area", "area", "Metric", "Square decimeter", "dm2", "dm²", 100, 0),
			new EUType("Area", "area", "Metric", "Square centimeter", "cm2", "cm²", 10000, 0),
			new EUType("Area", "area", "Metric", "Square millimeter", "mm2", "mm²", 1000000, 0),
			new EUType("Area", "area", "Metric", "Square micrometer", "um2", "µm²", 1000000000000, 0),
			new EUType("Area", "area", "Metric", "Square nanometer", "nm2", "nm²", 1E+18f, 0),
			new EUType("Area", "area", "British/American", "Township", "township", "Township", 1.07E-08f, 0),
			new EUType("Area", "area", "British/American", "Square mile", "square mile", "Square mile", 3.86E-07f, 0),
			new EUType("Area", "area", "British/American", "Homestead", "homestead", "Homestead", 1.54E-06f, 0),
			new EUType("Area", "area", "British/American", "Acre", "acre", "Acre", 0.000247f, 0),
			new EUType("Area", "area", "British/American", "Rood", "rood", "Rood", 0.000988f, 0),
			new EUType("Area", "area", "British/American", "Square rod", "rod2", "Square rod", 0.04f, 0),
			new EUType("Area", "area", "British/American", "Square", "square", "Square", 0.11f, 0),
			new EUType("Area", "area", "British/American", "Square yard", "yr2", "yr²", 1.2f, 0),
			new EUType("Area", "area", "British/American", "Square foot", "ft2", "ft²", 10.76f, 0),
			new EUType("Area", "area", "British/American", "Square inch", "in2", "in²", 1550, 0),
			new EUType("Area", "area", "Japanese", "Tsubo", "tsubo", "Tsubo", 0.3f, 0),
			new EUType("Area", "area", "Japanese", "Cho", "cho", "Cho", 100.83f, 0),
			new EUType("Area", "area", "Japanese", "Tann", "tann", "Tann", 1008.33f, 0),
			new EUType("Area", "area", "Japanese", "Se", "se", "Se", 10083.33f, 0),
			new EUType("Area", "area", "Other", "Metric dunam", "metric dunam", "Metric dunam", 0.001f, 0),
			new EUType("Area", "area", "Other", "Cypriot dunam", "cypriot dunam", "Cypriot dunam", 0.000747f, 0),
			new EUType("Area", "area", "Other", "Iraqi dunam", "iraqi dunam", "Iraqi dunam", 0.0004f, 0),
			new EUType("Area", "area", "Other", "Greek stremma", "greek stremma", "Greek stremma", 0.001f, 0),
			new EUType("Area", "area", "Other", "Football pitch", "football pitch", "Football pitch", 0.00014f, 0),
			new EUType("Volume", "volume", "Metric", "Cubic meter", "m3", "m³", 1, 0),
			new EUType("Volume", "volume", "Metric", "Cubic kilometer", "km3", "km³", 1E-09f, 0),
			new EUType("Volume", "volume", "Metric", "Hectoliter", "hectoliter", "Hectoliter", 10, 0),
			new EUType("Volume", "volume", "Metric", "Decaliter", "decaliter", "Decaliter", 100, 0),
			new EUType("Volume", "volume", "Metric", "Cubic decimeter", "dm3", "Cubic decimeter", 1000, 0),
			new EUType("Volume", "volume", "Metric", "Liter", "liter", "Liter", 1000, 0),
			new EUType("Volume", "volume", "Metric", "Deciliter", "dl", "Deciliter", 10000, 0),
			new EUType("Volume", "volume", "Metric", "Centiliter", "cl", "Centiliter", 100000, 0),
			new EUType("Volume", "volume", "Metric", "Cubic centimeter", "cm3", "Cubic centimeter", 1000000, 0),
			new EUType("Volume", "volume", "Metric", "Milliliter", "ml", "Milliliter", 1000000, 0),
			new EUType("Volume", "volume", "Metric", "Cubic millimeter", "mm3", "Cubic millimeter", 1000000000, 0),
			new EUType("Volume", "volume", "Metric", "Microliter", "ul", "Microliter", 1000000000, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Barrel", "barrel", "Barrel", 6.11f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Bushel", "bu", "bu", 27.5f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Peck", "pk", "pk", 109.98f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Gallon", "gal", "gal", 219.97f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Quart", "qt", "qt", 879.88f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Pint", "pt", "pt", 1759.75f, 0),
			new EUType("Volume", "volume", "British imperial liquid/dry", "Fluid ounce", "oz", "oz", 35195.01f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Acre foot", "acre foot", "Acre foot", 0.000811f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Cubic yard", "yd3", "yd³", 1.31f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Barrel", "barrel", "Barrel", 6.29f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Cubic foot", "ft3", "ft³", 35.31f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Gallon", "gal", "gal", 264.17f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Quart", "qt", "qt", 1056.69f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Pint", "pt", "pt", 2113.38f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Gill", "gill", "Gill", 8453.51f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Fluid ounce", "oz", "oz", 33814.02f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Cubic inch", "in3", "in³", 61023.76f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Fluid dram", "fluid dram", "Fluid dram", 270512.2f, 0),
			new EUType("Volume", "volume", "US liquid measure", "Minim", "minim", "Minim", 16230730, 0),
			new EUType("Volume", "volume", "US dry measure", "Barrel", "barrel", "Barrel", 8.65f, 0),
			new EUType("Volume", "volume", "US dry measure", "Bushel", "bu", "bu", 28.38f, 0),
			new EUType("Volume", "volume", "US dry measure", "Peck", "pk", "pk", 113.51f, 0),
			new EUType("Volume", "volume", "US dry measure", "Gallon", "gal", "gal", 227.02f, 0),
			new EUType("Volume", "volume", "US dry measure", "Quart", "qt", "qt", 908.08f, 0),
			new EUType("Volume", "volume", "US dry measure", "Pint", "pt", "pt", 1816.17f, 0),
			new EUType("Volume", "volume", "US dry measure", "Gill", "gill", "Gill", 7264.67f, 0),
			new EUType("Volume", "volume", "US dry measure", "Board foot", "FBM", "FBM", 423.78f, 0),
			new EUType("Volume", "volume", "Japanese", "Koku", "koku", "Koku", 5.54f, 0),
			new EUType("Volume", "volume", "Japanese", "To", "to", "To", 55.44f, 0),
			new EUType("Volume", "volume", "Japanese", "Sho", "sho", "Sho", 554.35f, 0),
			new EUType("Volume", "volume", "Japanese", "Go", "go", "Go", 5543.55f, 0),
			new EUType("Volume", "volume", "Cooking (US)", "Cup", "cup", "Cup", 4226.75f, 0),
			new EUType("Volume", "volume", "Cooking (US)", "Tablespoon", "tablespoon", "Tablespoon", 67628.03f, 0),
			new EUType("Volume", "volume", "Cooking (US)", "Teaspoon", "teaspoon", "Teaspoon", 202884.1f, 0),
			new EUType("Volume", "volume", "Cooking (metric)", "Tablespoon", "tablespoon", "Tablespoon", 66666.67f, 0),
			new EUType("Volume", "volume", "Cooking (metric)", "Teaspoon", "teaspoon", "Teaspoon", 200000, 0),
			new EUType("Volume", "volume", "Cooking (metric)", "Spice measure", "spice measure", "Spice measure", 1000000, 0),
			new EUType("Force", "force", "Metric", "Newton", "N", "N", 1, 0),
			new EUType("Force", "force", "Metric", "Nanonewton", "nN", "nN", 1000000000, 0),
			new EUType("Force", "force", "Metric", "Micronewton", "uN", "µN", 1000000, 0),
			new EUType("Force", "force", "Metric", "Millinewton", "mN", "mN", 1000, 0),
			new EUType("Force", "force", "Metric", "Kilonewton", "kN", "kN", 0.001f, 0),
			new EUType("Force", "force", "Metric", "Meganewton", "MN", "MN", 1E-06f, 0),
			new EUType("Force", "force", "Metric", "Giganewton", "GN", "GN", 1E-09f, 0),
			new EUType("Force", "force", "Metric", "Dyne", "dyn", "dyn", 100000, 0),
			new EUType("Force", "force", "Metric", "Powndal", "pdl", "pdl", 7.23f, 0),
			new EUType("Force", "force", "Metric", "Joule per meter", "J/m", "J/m", 1, 0),
			new EUType("Force", "force", "Metric", "Pascal per square meter", "Pa/m2", "Pa/m²", 1, 0),
			new EUType("Force", "force", "Metric", "Kilopond", "kp", "kp", 0.1f, 0),
			new EUType("Force", "force", "Metric", "Sthène", "sn", "sn", 0.001f, 0),
			new EUType("Force", "force", "Metric", "Kip", "kip", "kip", 0.000225f, 0),
			new EUType("Force", "force", "Metric", "Kilogram-force", "kgf", "kgf", 0.1f, 0),
			new EUType("Force", "force", "Metric", "Ton-force", "tnf", "tnf", 0.000102f, 0),
			new EUType("Force", "force", "Metric", "Pound-force", "lbf", "lbf", 0.22f, 0),
			new EUType("Force", "force", "Metric", "Short ton-force", "short tnf", "short tnf", 0.000112f, 0),
			new EUType("Force", "force", "Metric", "Long ton-force", "long tnf", "long tnf", 0.0001f, 0),
			new EUType("Force", "force", "Metric", "Ounce-force", "ozf", "ozf", 3.6f, 0),
			new EUType("Force", "force", "Metric", "Gravet-force", "gravet-force", "Gravet-force", 101.97f, 0),
			new EUType("Force", "force", "force", "Milligrave-force", "mGf", "mGf", 101.97f, 0),
			new EUType("Force", "force", "Metric", "Grave-force", "Gf", "Gf", 0.1f, 0),
			new EUType("Pressure", "pressure", "Metric", "Pascal", "Pa", "Pa", 1, 0),
			new EUType("Pressure", "pressure", "Metric", "Megapascal", "MPa", "MPa", 1E-06f, 0),
			new EUType("Pressure", "pressure", "Metric", "Bar", "bar", "Bar", 1E-05f, 0),
			new EUType("Pressure", "pressure", "Metric", "kgf/cm²", "kgf/cm2", "kgf/cm²", 1.02E-05f, 0),
			new EUType("Pressure", "pressure", "Metric", "Kilopascal", "kPa", "kPa", 0.001f, 0),
			new EUType("Pressure", "pressure", "Metric", "Hectopascal", "hPa", "hPa", 0.01f, 0),
			new EUType("Pressure", "pressure", "Metric", "Millibar", "millibar", "mBar", 0.01f, 0),
			new EUType("Pressure", "pressure", "Metric", "kgf/m²", "kgf/m2", "kgf/m²", 0.1f, 0),
			new EUType("Pressure", "pressure", "Avoirdupois (US)", "Kilopound per square inch", "ksi", "ksi", 1.45E-07f, 0),
			new EUType("Pressure", "pressure", "Avoirdupois (US)", "Pound per square inch", "psi", "psi", 0.000145f, 0),
			new EUType("Pressure", "pressure", "Avoirdupois (US)", "Pound per square foot", "psf", "psf", 0.02f, 0),
			new EUType("Pressure", "pressure", "Water", "Metre of water", "mH2O", "mH2O", 0.000102f, 0),
			new EUType("Pressure", "pressure", "Water", "Centimetre of water", "cmH2O", "cmH2O", 0.01f, 0),
			new EUType("Pressure", "pressure", "Water", "Foot of water", "ftH2O", "ftH2O", 0.000335f, 0),
			new EUType("Pressure", "pressure", "Water", "Inch of water", "inH2O", "inH2O", 0.00401f, 0),
			new EUType("Pressure", "pressure", "Atmosphere", "Physical atmosphere", "atm", "atm", 9.87E-06f, 0),
			new EUType("Pressure", "pressure", "Atmosphere", "Technical atmosphere", "technical atmosphere", "Technical atmosphere", 1.02E-05f, 0),
			new EUType("Pressure", "pressure", "Mercury", "Inch of mercury", "inHg", "inHg", 0.000295f, 0),
			new EUType("Pressure", "pressure", "Mercury", "Centimetres of mercury", "cmHg", "cmHg", 0.00075f, 0),
			new EUType("Pressure", "pressure", "Mercury", "Millimetres of mercury", "mmHg", "mmHg", 0.01f, 0),
			new EUType("Pressure", "pressure", "Mercury", "Torr", "torr", "torr", 0.01f, 0),
			new EUType("Current", "current", "Metric", "Ampere", "A", "A", 1, 0),
			new EUType("Current", "current", "Metric", "Nanoampere", "nA", "nA", 1000000000, 0),
			new EUType("Current", "current", "Metric", "Microampere", "uA", "µA", 1000000, 0),
			new EUType("Current", "current", "Metric", "Milliampere", "mA", "mA", 1000, 0),
			new EUType("Current", "current", "Metric", "Kiloampere", "kA", "kA", 0.001f, 0),
			new EUType("Current", "current", "Metric", "Megaampere", "MA", "MA", 1E-06f, 0),
			new EUType("Current", "current", "Metric", "Gigaampere", "GA", "GA", 1E-09f, 0),
			new EUType("Current", "current", "Metric", "Abampere", "aA", "aA", 0.1f, 0),
			new EUType("Current", "current", "Metric", "Coulomb per second", "C/s", "C/s", 1, 0),
			new EUType("Resistance", "resistance", "Metric", "Ohm", "ohm", "Ω", 1, 0),
			new EUType("Resistance", "resistance", "Metric", "Nanoohm", "nOhm", "nΩ", 1000000000, 0),
			new EUType("Resistance", "resistance", "Metric", "Microohm", "µOhm", "µΩ", 1000000, 0),
			new EUType("Resistance", "resistance", "Metric", "Milliohm", "mOhm", "mΩ", 1000, 0),
			new EUType("Resistance", "resistance", "Metric", "Kiloohm", "kOhm", "kΩ", 0.001f, 0),
			new EUType("Resistance", "resistance", "Metric", "Megaohm", "MOhm", "MΩ", 1E-06f, 0),
			new EUType("Resistance", "resistance", "Metric", "Gigaohm", "GOhm", "GΩ", 1E-09f, 0),
			new EUType("Resistance", "resistance", "Metric", "Abohm", "abOhm", "abΩ", 1000000000, 0),
			new EUType("Resistance", "resistance", "Metric", "Volt per ampere", "V/A", "V/A", 1, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Farad", "F", "F", 1, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Decafarad", "daF", "daF", 0.1f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Hectofarad", "hF", "hF", 0.01f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Kilofarad", "kF", "kF", 0.001f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Megafarad", "MF", "MF", 1E-06f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Gigafarad", "GF", "GF", 1E-09f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Terafarad", "TF", "TF", 1E-12f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Petafarad", "PF", "PF", 1E-15f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Exafarad", "EF", "EF", 1E-18f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Zettafarad", "ZF", "ZF", 1E-21f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Yottafarad", "YF", "YF", 1E-24f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Decifarad", "dF", "dF", 10, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Centifarad", "cF", "cF", 100, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Millifarad", "mF", "mF", 1000, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Microfarad", "uF", "µF", 1000000, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Nanofarad", "nF", "nF", 1000000000, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Picafarad", "pF", "pF", 1000000000000, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Femtofarad", "fF", "fF", 1E+15f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Attofarad", "aF", "aF", 1E+18f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Zeptofarad", "zF", "zF", 1E+21f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Yoctofarad", "yF", "yF", 1E+24f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Coulomb per volt", "C/V", "C/V", 1, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Abfarad", "abF", "abF", 1E-09f, 0),
			new EUType("Capcitance", "capcitance", "Metric", "Statfarad", "statF", "statF", 899000000000, 0),
			new EUType("Charge", "charge", "Metric", "Coulomb", "C", "C", 1, 0),
			new EUType("Charge", "charge", "Metric", "Nanocoulomb", "nC", "nC", 1000000000, 0),
			new EUType("Charge", "charge", "Metric", "Microcoulomb", "uC", "µC", 1000000, 0),
			new EUType("Charge", "charge", "Metric", "Millicoulomb", "mC", "mC", 1000, 0),
			new EUType("Charge", "charge", "Metric", "Kilocoulomb", "kC", "kC", 0.001f, 0),
			new EUType("Charge", "charge", "Metric", "Megacoulomb", "MC", "MC", 1E-06f, 0),
			new EUType("Charge", "charge", "Metric", "Abcoulomb", "abC", "abC", 0.1f, 0),
			new EUType("Charge", "charge", "Metric", "Milliampere-hour", "mAh", "mAh", 0.28f, 0),
			new EUType("Charge", "charge", "Metric", "Ampere-hour", "Ah", "Ah", 0.000278f, 0),
			new EUType("Charge", "charge", "Metric", "Faraday", "F", "F", 1.04E-05f, 0),
			new EUType("Charge", "charge", "Metric", "Statcoulomb", "statC", "statC", 2997924580, 0),
			new EUType("Charge", "charge", "Metric", "Elemetary charge", "e", "e", 6.24E+18f, 0),
			new EUType("Conductance", "conductance", "Metric", "Siemens", "S", "S", 1, 0),
			new EUType("Conductance", "conductance", "Metric", "Nanosiemens", "nS", "nS", 1000000000, 0),
			new EUType("Conductance", "conductance", "Metric", "Microsiemens", "uS", "µS", 1000000, 0),
			new EUType("Conductance", "conductance", "Metric", "Millisiemens", "mS", "mS", 1000, 0),
			new EUType("Conductance", "conductance", "Metric", "Kilosiemens", "kS", "kS", 0.001f, 0),
			new EUType("Conductance", "conductance", "Metric", "Megasiemens", "MS", "MS", 1E-06f, 0),
			new EUType("Conductance", "conductance", "Metric", "Gigasiemens", "GS", "GS", 1E-09f, 0),
			new EUType("Acceleration", "acceleration", "Metric", "meter per socond squared", "m/s2", "m/s²", 1, 0),
			new EUType("Acceleration", "acceleration", "Metric", "foot per second squared", "ft/s2", "ft/s²", 3.28f, 0),
			new EUType("Acceleration", "acceleration", "Metric", "GAL", "Gal", "Gal", 100, 0),
			new EUType("Acceleration", "acceleration", "Metric", "Milligal", "mgal", "mgal", 1000000, 0),
			new EUType("Acceleration", "acceleration", "Metric", "Standard gravity", "sg", "sg", 0.1f, 0),
			new EUType("Speed", "speed", "Metric", "Meter per socond", "m/s", "m/s", 1, 0),
			new EUType("Speed", "speed", "Metric", "Kilometer per second", "km/s", "km/s", 0.001f, 0),
			new EUType("Speed", "speed", "Metric", "Kilometer per hour", "km/h", "km/h", 3.6f, 0),
			new EUType("Speed", "speed", "Metric", "Millimeter per second", "mm/s", "mm/s", 1000, 0),
			new EUType("Speed", "speed", "Metric", "Micrometer per second", "um/s", "µm/s", 1000000, 0),
			new EUType("Speed", "speed", "British/American", "Mile per second", "mi/s", "mi/s", 0.000173f, 0),
			new EUType("Speed", "speed", "British/American", "Mile per hour", "mph", "mph", 0.62f, 0),
			new EUType("Speed", "speed", "British/American", "Foot per second", "ft/s", "ft/s", 0.91f, 0),
			new EUType("Speed", "speed", "Nautical", "Knot", "knot", "knot", 0.54f, 0),
			new EUType("Time", "time", "Metric", "Second", "second", "s", 1, 0),
			new EUType("Time", "time", "Metric", "Year", "Y", "Year", 3.17E-08f, 0),
			new EUType("Time", "time", "Metric", "Month", "month", "Month", 3.8E-07f, 0),
			new EUType("Time", "time", "Metric", "Week", "week", "Week", 1.65E-06f, 0),
			new EUType("Time", "time", "Metric", "Day", "day", "Day", 1.16E-05f, 0),
			new EUType("Time", "time", "Metric", "Hour", "hour", "Hour", 0.000278f, 0),
			new EUType("Time", "time", "Metric", "Minute", "min", "Min", 0.02f, 0),
			new EUType("Time", "time", "Metric", "Millisecond", "ms", "ms", 1000, 0),
			new EUType("Time", "time", "Metric", "Microsecond", "us", "µs", 1000000, 0),
			new EUType("Time", "time", "Metric", "Nanosecond", "ns", "ns", 1000000000, 0),
//			new EUType("Time", "time", "Metric", "DateTime([YY]YY-MM-DD hh:mm:ss)", "datetime", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Date([YY]YY-MM-DD)", "date", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Date([YY]YY-MM)", "date[YY-MM]", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Date(MM-DD)", "date[MM-DD]", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Time(hh:mm:ss)", "time", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Time(hh:mm)", "time[hh:mm]", "", 1, 0),
//			new EUType("Time", "time", "Metric", "Time(mm:ss)", "time[mm:ss]", "", 1, 0),
			new EUType("Mass", "mass", "Metric", "Kilogram", "kg", "kg", 1, 0),
			new EUType("Mass", "mass", "Metric", "Ton", "t", "t", 0.001f, 0),
			new EUType("Mass", "mass", "Metric", "Kilonewton", "kN", "kN", 0.01f, 0),
			new EUType("Mass", "mass", "Metric", "Hectogram", "hg", "hg", 10, 0),
			new EUType("Mass", "mass", "Metric", "Gram", "g", "g", 1000, 0),
			new EUType("Mass", "mass", "Metric", "Carat", "c", "c", 5000, 0),
			new EUType("Mass", "mass", "Metric", "Centigram", "cg", "cg", 100000, 0),
			new EUType("Mass", "mass", "Metric", "Milligram", "mg", "mg", 1000000, 0),
			new EUType("Mass", "mass", "Metric", "Microgram", "ug", "µg", 1000000000, 0),
			new EUType("Mass", "mass", "Metric", "Nanogram", "ng", "ng", 1000000000000, 0),
			new EUType("Mass", "mass", "Metric", "Atomic mass unit", "u", "u", 6.02E+26f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Long ton", "l.t.", "l.t.", 0.000984f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Short ton", "s.t.", "s.t.", 0.0011f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Long hundredweight", "long hundredweight", "Long hundredweight", 0.02f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Short hundredweight", "short hundredweight", "Short hundredweight", 0.02f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Stone", "st", "st", 0.16f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Pound", "lb", "lb", 2.2f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Ounce", "oz", "oz", 35.27f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Dram", "dr", "dr", 564.38f, 0),
			new EUType("Mass", "mass", "Avoirdupois (US)", "Grain", "gr", "gr", 15432.36f, 0),
			new EUType("Mass", "mass", "Troy", "Pound", "lbt", "lbt", 2.68f, 0),
			new EUType("Mass", "mass", "Troy", "Ounce", "oz", "oz", 32.15f, 0),
			new EUType("Mass", "mass", "Troy", "Pennyweight", "pennyweight", "Pennyweight", 642.95f, 0),
			new EUType("Mass", "mass", "Troy", "Carat", "c", "c", 4877.56f, 0),
			new EUType("Mass", "mass", "Troy", "Grain", "gr", "gr", 15432.36f, 0),
			new EUType("Mass", "mass", "Troy", "Mite", "mite", "Mite", 308616.4f, 0),
			new EUType("Mass", "mass", "Troy", "Doite", "doite", "Doite", 7406796f, 0),
			new EUType("Mass", "mass", "Japanese", "Koku", "koku", "Koku", 0.01f, 0),
			new EUType("Mass", "mass", "Japanese", "Kann", "kann", "Kann", 0.27f, 0),
			new EUType("Mass", "mass", "Japanese", "Kinn", "kinn", "Kinn", 1.67f, 0),
			new EUType("Mass", "mass", "Japanese", "Monnme", "monnme", "Monnme", 266.64f, 0),
			new EUType("Mass", "mass", "Chinese", "Tael", "tael", "Tael", 26.46f, 0),
			new EUType("Mass", "mass", "Chinese", "Ku ping", "kuping", "Ku ping", 26.8f, 0),
			new EUType("Voltage", "volt", "Metric", "Nanovolt", "nV", "nV", 1000000000, 0),
			new EUType("Voltage", "volt", "Metric", "Microvolt", "uV", "µV", 1000000, 0),
			new EUType("Voltage", "volt", "Metric", "Millivolt", "mV", "mV", 1000, 0),
			new EUType("Voltage", "volt", "Metric", "Volt", "V", "V", 1, 0),
			new EUType("Voltage", "volt", "Metric", "Kilovolt", "kV", "kV", 0.001f, 0),
			new EUType("Voltage", "volt", "Metric", "Megavolt", "MV", "MV", 1E-06f, 0),
			new EUType("Voltage", "volt", "Metric", "Gigavolt", "GV", "GV", 1E-09f, 0),
			new EUType("Voltage", "volt", "Metric", "Watt per ampere", "W/A", "W/A", 1, 0),
			new EUType("Voltage", "volt", "Metric", "Abvolt", "abV", "abV", 100000000, 0),
			new EUType("Voltage", "volt", "Metric", "Statvolt", "stV", "stV", 0.00334f, 0),
		};

		/// <summary>
		/// dictionary: type -> EUType[]
		/// </summary>
		static Dictionary<string, EUType[]> _dctType2EUTypes = new Dictionary<string, EUType[]>();

		/// <summary>
		/// dictionary: type.system -> EUType[]
		/// </summary>
		static Dictionary<string, EUType[]> _dctTypeSystem2EUTypes = new Dictionary<string, EUType[]>();

		/// <summary>
		/// dictionary: short type --> type
		/// </summary>
		static Dictionary<string, string> _dctShortType2Type = new Dictionary<string, string>();

		/// <summary>
		/// dictionary: short name --> name
		/// </summary>
		static Dictionary<string, string> _dctShortName2Name = new Dictionary<string, string>();

		/// <summary>
		/// dictionary: various key(eu type, short type, name, short name) -> EUType
		/// </summary>
		static Dictionary<string, EUType> _dctEUTypes = new Dictionary<string, EUType>();

		static EU()
		{
			foreach (var item in _EUTypeList)
			{
				#region create key to EUType dictionary
				// dictionary: type -> eutype
				if (AddEUTypeToDictionary(item.Type, item) == false)
				{
					//throw new ArgumentException($"The Key({item.Type}) to EUType is duplicated.");
					//System.Diagnostics.Trace.WriteLine($"The [type] Key({item.Type}) to EUType is duplicated.");
				}

				// dictionary: shorttype -> eutype
				if (AddEUTypeToDictionary(item.ShortType, item) == false)
				{
					//throw new ArgumentException($"The Key({item.ShortType}) to EUType is duplicated.");
					//System.Diagnostics.Trace.WriteLine($"The [short type] Key({item.ShortType}) to EUType is duplicated.");
				}

				// dictionary: name -> eutype
				if (AddEUTypeToDictionary(item.Name, item) == false)
				{
					//throw new ArgumentException($"The Key({item.Name}) to EUType is duplicated.");
				}

				// dictionary: shortname -> eutype
				if (AddEUTypeToDictionary(item.ShortName, item) == false)
				{
					//throw new ArgumentException($"The Key({item.ShortName}) to EUType is duplicated.");
				}

				#endregion

				#region create dictionary: shorttype -> type
				if (_dctShortType2Type.TryGetValue(item.ShortType, out _) == false)
				{
					_dctShortType2Type[item.ShortType] = item.Type;
				}
				#endregion

				#region create dictionary: shortname -> name
				if (_dctShortName2Name.TryGetValue(item.ShortName, out _) == false)
				{
					_dctShortName2Name[item.ShortName] = item.Type;
				}
				#endregion

				#region create dictionary : type -> eutype list
				string lastType = string.Empty;
				List<EUType> lstEUTypes = new List<EUType>();

				if (item.Type != lastType)
				{
					if (!string.IsNullOrEmpty(lastType))
					{
						_dctType2EUTypes[lastType] = lstEUTypes.ToArray();
						lstEUTypes = new List<EUType>();
					}
				}
				lstEUTypes.Add(item);
				lastType = item.Type;
				#endregion

				#region create dictionary: type.system -> eutype
				string lastTypeSystem = string.Empty;
				List<EUType> lstTypeSystems = new List<EUType>();

				string strTypeSystem = string.Format($"{item.Type}.{item.System}");
				if (strTypeSystem != lastTypeSystem)
				{
					if (!string.IsNullOrEmpty(lastTypeSystem))
					{
						_dctTypeSystem2EUTypes[lastTypeSystem] = lstTypeSystems.ToArray();
						lstTypeSystems = new List<EUType>();
					}
				}
				lstTypeSystems.Add(item);
				lastTypeSystem = strTypeSystem;
				#endregion
			}
		}

		private static bool AddEUTypeToDictionary(string key, EUType item)
		{
			if (_dctEUTypes.TryGetValue(key, out _) == false)
			{
				_dctEUTypes[key] = item;
				return true;
			}
			else
			{
				System.Diagnostics.Trace.WriteLine($"The key {key} to EUType is duplicated.");
				return false;
			}
		}

		public EU(string strEU)
		{
			_eu = _dctEUTypes[strEU];
		}

		public static float Convert(float value, EU eu1, EU eu2)
		{
			return value * eu2.Scale / eu1.Scale;
		}

		public static bool IsExchangable(EU eu1, EU eu2)
		{
			if (eu1._eu.Type == eu1._eu.Type)
				return true;

			return false;
		}

		public static bool IsDividable(EU eU1, EU eU2)
		{
			throw new NotImplementedException();
		}

		public static bool IsMultiplicable(EU eU1, EU eU2)
		{
			throw new NotImplementedException();
		}

		public static bool IsExchangable(string strEU1, string strEU2)
		{
			EU eu1 = new EU(strEU1);
			EU eu2 = new EU(strEU2);

			return IsExchangable(eu1, eu2);
		}

		public string Type { get { return _eu.Type; } }
		public string ShortType { get { return _eu.ShortType; } }
		public string SystemType { get { return _eu.System; } }
		public string Name { get { return _eu.Name; } }
		public string ShortName { get { return _eu.ShortName; } }
		public string DisplayName { get { return _eu.DisplayName; } }
		public float Scale { get { return _eu.Scale; } }
		public float Offset { get { return _eu.Offset; } }
	}
}
